﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using Snowdreamist.Runtime.Services;

namespace Snowdreamist.Threading
{
    public delegate void TaskCompletedCallback(TaskResult result);

    public delegate void TaskStateChangedCallback(TaskState oldState, TaskState newState);

    public interface ITasksDispatcher : IRuntimeService
    {
        int MaxConcurrentTasksNumber { get; }

        int IdleTasksNumber { get; }

        int WaitingTasksNumber { get; }

        int RunningTasksNumber { get; }

        CancellationToken Run(
            Delegate method,
            TaskCompletedCallback completedCallback,
            TaskStateChangedCallback stateChangedCallback,
            params object[] args
            );
    }
}